package com.sys.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sys.dao.AdministratorDao;
import com.sys.entity.Administrator;
import com.sys.service.AdministratorService;

@Service
public class AdministratorServiceImpl implements AdministratorService{
		
	@Autowired
	private AdministratorDao administratorDao;
	
	@Override
	public Map<String, Object> getAllAdministrator( String nickname, String realname, String password, Integer locks,
			String salt, String email, String phone, String createtime, String updatetime, Integer del, Integer page,
			Integer limit) {
		System.out.println(administratorDao);
		Map<String, Object> prams=new HashMap<String, Object>();
		prams.put("nickname", nickname);
		prams.put("realname", realname);
		prams.put("password", password);
		prams.put("locks", locks);
		prams.put("salt", salt);
		prams.put("email", email);
		prams.put("phone", phone);
		prams.put("createtime", createtime);
		prams.put("updatetime", updatetime);
		prams.put("del", del);
		page = (page - 1) * limit;
		prams.put("page", page);
		prams.put("limit", limit);
		
		List<Administrator> list=administratorDao.getAllAdministrator(prams);
		int total=administratorDao.getAllAdministratorCount(prams);
		Map<String, Object> map=new HashMap<String, Object>();
		map.put("list", list);
		map.put("total", total);
		return map;
	}

	@Override
	public int addAdministrator(Administrator administrator) {
		int len=administratorDao.addAdministrator(administrator);
		return len;
	}

	@Override
	public int updateAdministrator(Administrator administrator) {
		int len=administratorDao.updateAdministrator(administrator);
		return len;
	}

	@Override
	public int deleteAdministrator(Administrator administrator) {
		int len=administratorDao.deleteAdministrator(administrator);
		return len;
	}

}
